<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Title</title>
  </head>
  <body>
    <script>
      // function showAccountTitle(urlType) {
      //   let accountTitle = "";
      //   if (urlType == "StartOpening") {
      //     accountTitle = "发起开户";
      //   } else if (urlType == "StartChange") {
      //     accountTitle = "发起变更";
      //   } else if (urlType == "StartPinHouseholds") {
      //     accountTitle = "发起销户";
      //   } else if (urlType == "AccountDetail") {
      //     if (operationType == "1") {
      //       accountTitle = "账户开户详情";
      //     } else if (operationType == "2") {
      //       accountTitle = "账户变更详情";
      //     } else if (operationType == "3") {
      //       accountTitle = "账户销户详情";
      //     }
      //   }
      //   return accountTitle;
      // }

      //账户策略
      const accountStrategy = {
        1: () => "账户开户详情",
        2: () => "账户变更详情",
        3: () => "账户销户详情",
      };

      // 采用策略模式优化
      const strategy = {
        StartOpening: () => "发起开户",
        StartChange: () => "发起变更",
        StartPinHouseholds: () => "发起销户",
        AccountDetail: (operationType) => accountStrategy[operationType](),
      };

      const showAccountTitle = (urlType, operationType) => {
        return strategy[urlType](operationType);
      };

      console.log(showAccountTitle("StartOpening"));
      console.log(showAccountTitle("StartChange"));
      console.log(showAccountTitle("AccountDetail", "1"));
    </script>
  </body>
</html>
